#ifndef _SYS_H
#define _SYS_H


#define NR_fork 	0
#define NR_singal 	1
#define NR_sigaction  	2
#define NR_free_process 3
#define NR_write 	4

#define system_call0(type,name) \
type name()\
{\
	unsigned int res;\
	unsigned int fun_id=NR_##name;\
	asm volatile(\
		"ldr r0,%1 \n\t"\
		"swi \n\t"\
		"str r0,%0 \n\t"\
		:"=m"(res)\
		:"m"(fun_id)\
		:"r0","memory"\
	);\
	return (type)res;\
}


#define system_call1(type,name,atype,a) \
type name(atype a)\
{\
	unsigned int res;\
	unsigned int fun_id=NR_##name;\
	asm volatile(\
		"ldr r0,%1 \n\t"\
		"ldr r1,%2 \n\t"\
		"swi \n\t"\
		"str r0,%0 \n\t"\
		:"=m"(res)\
		:"m"(fun_id),"m"(a)\
		:"r0","r1","memory"\
	);\
	return (type)res;\
}


#define system_call2(type,name,atype,a,btype,b) \
type name(atype a,btype b)\
{\
	unsigned int res;\
	unsigned int fun_id=NR_##name;\
	asm volatile(\
		"ldr r0,%1 \n\t"\
		"ldr r1,%2 \n\t"\
		"ldr r2,%3 \n\t"\
		"swi \n\t"\
		"str r0,%0 \n\t"\
		:"=m"(res)\
		:"m"(fun_id),"m"(a),"m"(b)\
		:"r0","r1","r2","memory"\
	);\
	return (type)res;\
}


#define system_call3(type,name,atype,a,btype,b,ctype,c) \
type name(atype a,btype b,ctype c)\
{\
	unsigned int res;\
	unsigned int fun_id=NR_##name;\
	asm volatile(\
		"ldr r0,%1 \n\t"\
		"ldr r1,%2 \n\t"\
		"ldr r2,%3 \n\t"\
		"ldr r3,%4 \n\t"\
		"swi \n\t"\
		"str r0,%0 \n\t"\
		:"=m"(res)\
		:"m"(fun_id),"m"(a),"m"(b),"m"(c)\
		:"r0","r1","r2","r3","memory"\
	);\
	return (type)res;\
}

#endif
